#include "CdupRequest.h"


CdupRequest::CdupRequest(void)
{
}


CdupRequest::~CdupRequest(void)
{
}

void CdupRequest::SendCDUP(void)
{
	send(m_nConn, "CDUP\r\n", 6, 0);
	m_nState = m_kCDUPenum::CDUP;
}

int CdupRequest::ResponseAnalysis(void)
{
	m_pcCopyParse = m_cCopyBuf;

	switch (*m_pcCopyParse)
	{
	case '2':
		if (m_nState == m_kCDUPenum::CDUP)
		{
			send(m_nConn, "PASV\r\n", 6, 0);
			m_nState = m_kCDUPenum::PASV;
		}
		else if (m_nState == m_kCDUPenum::PASV)
		{
			ResponsePASV();
			CreateDataConn();
			PutItemList();
			m_nState = m_kCDUPenum::NONE;
		}
		break;

	case '4':
		//make Data connection failed handle
		m_nState = m_kCDUPenum::NONE;
		AfxMessageBox(m_cCopyBuf);
		break;

	case '5':
		//make Data connection failed handle
		m_nState = m_kCDUPenum::NONE;
		AfxMessageBox(m_cCopyBuf);
		break;
	}
	return 0;
}